<!DOCTYPE html>
<html style="min-width: 1320px;">

	<head>
		<include file="common/head" />
		<link href="__PUBLIC__/css/friend.css?v=4.1.0" rel="stylesheet">
		<style>
			.input-group{
				margin-bottom: 10px;
				width: 100%;
			}
			#free_imgs{
				width: 260px;
				height: 260px;
			}
			.err_info{
				margin-bottom: 10px;
				padding-left: 20px;
				margin-top: -22px;
				color: red;
			}
			.toogl_tale{
				padding: 10px 20px;
			}
			.toogl_tale input{
				height: 40px;
			}
		</style>
	</head>

	<body class="gray-bg">
		<div class="wrapper wrapper-content  animated fadeInRight">
			<div class="row">
				<div class="col-sm-12">
					<div class="ibox " style="min-width: 1320px;">
						<div class="ibox-title">
							<h5>亲友圈管理</h5>
						</div>
						<div class="toogl_tale">
							<a href="__URL__/friend_list_new"><input type="button" value="微信亲友圈" class="btn btn-w-m btn-info"></a>
							<a href="__URL__/friend_list_xianliao"><input type="button" value="闲聊亲友圈" class="btn btn-w-m btn-default"></a>
						</div>
						<div class="toogl_body">
							<!--左上角的表头-->
							<div class="ibox-content">
								<a href="#" id="open_modal" data-target="" data-toggle="modal" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-plus"></span>新增亲友圈</a>
							</div>

							<div class="jqGrid_wrapper jqGrid_wrap-2 jqgrid_box">
								<!--渲染的表-->
								<table id="table_list_1" class="table table-bordered table_list">
									
								</table>
								<!--分页器-->
								<div id="pager_list_1"></div>
					       </div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<!--填写gid step2-->
		<div id="newModal1" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr" class=" modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
					<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
						<div class="ibox-title">
							<h5>新增亲友圈</h5>
							<div class="ibox-tools"  data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<form id="add_form1" method="post" action="__URL__/register_relatives_friends"><!--填新增的url-->
						 <div class="ibox-content jqGrid_wrapp_qx">
							<div class="form-inlin1">
								<input type="hidden" name="register_relatives_friends_id" id="add_form1_hide">
								<div class="input-group">
									<label class="input-group-addon" style="width: 160px">亲友圈id：</label>
									<input type="text" name="gid" id="gid" value="" class="form-control">
								</div>
								<div class="input-group">
                                    <label class="input-group-addon" style="width: 160px">亲友圈显示方式：</label>
                                    <select name="content_type" class="form-control gid_type">
                                        <option value="0" selected="selected">文字</option>
                                        <option value="1">图片</option>
                                    </select>
                                </div>

								<div class="input-group back_img_div" style="position: relative;display: none;">
                                    <label class="input-group-addon" style="width: 160px">显示的背景图：</label>
									<input id="upload_img" type="file" name="back_img" class="back_img" accept="image/png">
									<img class="back_img_img" id="img_show" src="" style="position: absolute;right: 0;height: 65px;top: 0;">
                                </div>
								<div class="back_img_tit" style="margin-bottom: 10px;font-size: 14px;color: #333;display: none">请上传容量小于500kb的png格式图片，不上传将使用默认图片</div>
								<!-- <div class="input-group back_img_time" style="display: none">
									<label class="input-group-addon" style="width: 160px">图片到期时间：</label>
									<input type="text" name="back_img_end_time" id="back_time" value="" class="form-control">
								</div> -->
								<div class="input-group">
									<label class="input-group-addon" style="width: 160px">备注：</label>
									<textarea type="text" name="describe"  value="" class="form-control" maxlength="100"></textarea>
								</div>
							</div>	
	                    </div>
						<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
							<input class="btn btn-w-m btn-info gid_last_step" type="button" value="上一步"/>
							<input class="btn btn-w-m btn-info" type="button" value="下一步" onclick="send_form_ele('#add_form1',rejqGrid3,false,'.form-inlin1')" />
						</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--填写gid end-->
		<!--注销此亲友圈的模态窗-->
		<div id="delModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr" class="modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2">
					<div class="ibox float-e-margins float-e-margins-2">
					<input type="hidden" value="" name="" class="register_relatives_friends_id_del" />
					<form id="repassword_form" action="__URL__/Cancellation_relatives_friends" method="post">
						<input type="hidden" value="" name="pid" class="pid_del" />
						<input type="hidden" value="" name="gid" class="gid_del" />
						<div class="ibox-title">
							<h5>消息提示</h5>
							<div class="ibox-tools" data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<div class="ibox-s ibox-s-zj" style="padding: 10px;">
							<p id="delModal_text">确定注销此亲友圈？</p>
						</div>
						<div class="ibox-butz" style="display: flex; justify-content: center;align-items: center;padding-bottom:10px ;">
							<input class="btn btn-w-m btn-info" type="button" onclick="del_gid()" value="确定" />
							<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消" style="margin-left: 10px;"/>
						</div>
					</form>
					</div>
				</div>
			</div>
		</div>
		<!--注销此亲友圈的模态窗end-->
		<!--删除此亲友圈的模态窗-->
		<div id="delModal2" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr" class="modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2">
					<div class="ibox float-e-margins float-e-margins-2">
					<input type="hidden" value="" name="" class="register_relatives_friends_id_del" />
					<form id="repassword_form2" action="__URL__/Cancellation_relatives_friends" method="post">
						<input type="hidden" value="" name="pid" class="pid_del" />
						<input type="hidden" value="" name="gid" class="gid_del" />
						<input type="hidden" value="" name="register_relatives_friends_id" class="register_relatives_friends_id_del" />
						<div class="ibox-title">
							<h5>消息提示</h5>
							<div class="ibox-tools" data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<div class="ibox-s ibox-s-zj" style="padding: 10px;">
							<p id="delModal_text">删除此亲友圈后，已续费的亲友圈不可恢复。是否删除？</p>
						</div>
						<div class="ibox-butz" style="display: flex; justify-content: center;align-items: center;padding-bottom:10px ;">
							<input class="btn btn-w-m btn-info" type="button" onclick="del_gid2()" value="确定" />
							<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消" style="margin-left: 10px;"/>
						</div>
					</form>
					</div>
				</div>
			</div>
		</div>
		<!--删除此亲友圈的模态窗end-->
		<!--注册代理的模态窗 step1-->
		<div id="newModal2" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr" class=" modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
					<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
						<div class="ibox-title">
							<h5>代理认证</h5>
							<div class="ibox-tools"  data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<form id="add_form2" method="post" action="__URL__/agency_certification"><!--填新增的url-->
						 <div class="ibox-content jqGrid_wrapp_qx">
							<div class="form-inlin2">
								<input type="hidden" value="1" name="bind_type"><!--隐藏的bind_type,微信传1，闲聊传2-->
								<div class="input-group">
									<label class="input-group-addon" style="width: 160px">地区选择：</label>
									<select name="" class="form-control area_c">
										<option value=" ">请选择地区</option>
									</select>
								</div>
                                <div class="input-group">
                                    <label class="input-group-addon" style="width: 160px">地区选择：</label>
                                    <select name="pid" class="form-control area">
                                        <option value=" ">请选择地区</option>
                                    </select>
                                </div>

								<div class="input-group group_id1">
									<label class="input-group-addon" style="width: 160px">代理认证账户：</label>
									<input type="text" name="username" id="username" value="" class="form-control">
								</div>
								
								<div class="input-group group_id1">
									<label class="input-group-addon" style="width: 160px">代理认证密码：</label>
									<input type="password" name="password" id="password" value="" class="form-control">
								</div>

								<div class="input-group group_id2" style="display: none">
									<label class="input-group-addon" style="width: 160px">用户ID：</label>
									<input type="text" name="aid" id="aid" value="" class="form-control">
								</div>

								<div class="input-group">
									<label class="input-group-addon" style="width: 160px">试用时间：</label>
									<input type="number" name="test_time" id="test_time" class="form-control" placeholder="请输入试用时间0-15(天)">
								</div>
							</div>	
	                    </div>
						<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
							<input class="btn btn-w-m btn-info" type="button" value="下一步" onclick="step1()" />
							
						</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--注册代理的模态窗end-->
		<!--绑定微信二维码的模态窗 step3-->
			<div id="newModal3" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
				<div id="gray_Nr" class=" modal-dialog">
					<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
						<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
							<div class="ibox-title">
								<h5>微信认证</h5>
								<div class="ibox-tools"  data-dismiss="modal">
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
							<form id="add_form3" method="post" action="__URL__/agency_certification"><!--填新增的url-->
								<div class="ibox-content jqGrid_wrapp_qx">
									<div class="form-inlin3" style="width: 350px;height: 540px;display: block;">
										<div id="login_box">
											<img id="er_img" src="__PUBLIC__/img/loading2.gif" />
											<p class="sub_title">使用手机微信扫码登录</p>
											<p class="sub_desc">网页版微信需要配合手机使用</p>
										</div>
									</div>	
								</div>
							</form>
						</div>
						<!-- <div class="ibox-butz" style="text-align: center;padding-bottom: 20px;"> 
							<input class="btn btn-w-m btn-info erweima_last_step" type="button" value="上一步" />
						</div> -->
					</div>
				</div>
			</div>
		<!--绑定微信二维码的模态窗end-->
		<!--获取群验证码的模态窗 step4-->
		<div id="newModal4" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static" >
			<div id="gray_Nr" class=" modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
					<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
						<div class="ibox-title">
							<h5>获取群验证码</h5>
							<div class="ibox-tools"  data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<form id="add_form4" method="post" action=""><!--填新增的url-->
							<div class="ibox-content jqGrid_wrapp_qx">
								<div class="form-inlin3" style="height: 540px;display: block;">
									<div id="login_box2">
										<p style="line-height: 2" class="title">请在要绑定的微信群内发送：</p>
										<p class="qunzhushou" style="font-size: 20px;font-weight: bolder;"></p>
									</div>
								</div>	
							</div>
							<div class="ibox_butz_only" style="text-align: center;padding-bottom: 20px;display: none">
								<input class="btn btn-w-m over_btn" type="button" data-dismiss="modal" value="关闭">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--获取群验证码的模态窗end-->	
		<!--更改亲友圈显示方式-->
		<div id="newModal5" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
				<div id="gray_Nr5" class=" modal-dialog">
					<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
						<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
							<div class="ibox-title">
								<h5>修改</h5>
								<div class="ibox-tools"  data-dismiss="modal">
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
							<form id="add_form5" method="post" action="__URL__/set_content_type"><!--填修改的url-->
							 <div class="ibox-content jqGrid_wrapp_qx">
								<div class="form-inlin5">
									<input type="text" name="register_relatives_friends_id" style="display: none" class="friends_id">
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">亲友圈显示方式：</label>
										<select name="content_type" class="form-control gid_type_change">
											<option value="0">文字</option>
											<option value="1" selected="selected">图片</option>
										</select>
									</div>
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">备注：</label>
										<textarea rows="3" name="describe_change" id="describe_change" value="" class="form-control"></textarea>
									</div>
									<div class="input-group back_img_div_change" style="position: relative;">
										<label class="input-group-addon" style="width: 160px">显示的背景图：</label>
										<input type="file" id="back_img_change" name="back_img" class="back_img_change" accept="image/png">
										<img class="back_img_show" id="back_img_change_show" src="" style="position: absolute;right: 0;height: 65px;top: 0;">
									</div>
									<div class="back_img_tit_change" style="margin-bottom: 10px;font-size: 14px;color: #333">请上传容量小于500kb的png格式图片，不上传将使用默认图片</div>
									<!-- <div class="input-group back_img_time_change" style="display: none">
										<label class="input-group-addon" style="width: 160px">图片到期时间：</label>
										<input type="text" name="back_img_end_time" id="back_time_change" value="" class="form-control">
									</div> -->
								</div>	
							</div>
							<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
								<input class="btn btn-w-m btn-info" type="button" value="修改" onclick="send_form_ele('#add_form5',change_gid_type_success,false,'.form-inlin5')" />
							</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		<!--更改亲友圈显示方式end-->
		<!--设为默认背景图-->
			<div id="del_img_Modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" data-backdrop="static">
				<div id="gray_Nr" class="modal-dialog">
					<div class="col-sm-7 col-zm-j col-zm-j2">
						<div class="ibox float-e-margins float-e-margins-2">
						<input type="hidden" value="" name="" class="register_relatives_friends_id_del" />
						<form id="delimg_form" action="__URL__/remove_back_img" method="post">
							<input type="hidden" value="" name="register_relatives_friends_id" class="del_img_id" />
							<div class="ibox-title">
								<h5>消息提示</h5>
								<div class="ibox-tools" data-dismiss="modal">
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
							<div class="ibox-s ibox-s-zj" style="padding: 10px;">
								<p id="delModal_text">确定更换为默认背景图？</p>
							</div>
							<div class="ibox-butz" style="display: flex; justify-content: center;align-items: center;padding-bottom:10px ;">
								<input class="btn btn-w-m btn-info" type="button" onclick="del_img_btn()" value="确定" />
								<input class="btn btn-w-m" type="button" data-dismiss="modal" value="取消" style="margin-left: 10px;"/>
							</div>
						</form>
						</div>
					</div>
				</div>
			</div>
		<!--设为默认背景图end-->

		<!--续费模态窗-->
		<div id="newModal6" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr5" class=" modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
					<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
						<div class="ibox-title">
							<h5>续费</h5>
							<div class="ibox-tools"  data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<form id="add_form6" method="post" action="__URL__/add_service_order"><!--续费的url-->
							<div class="ibox-content jqGrid_wrapp_qx">
								<div class="form-inlin1">
									<input type="text" name="register_relatives_friends_id" style="display: none" id="free_friend_id_hide">
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">亲友圈ID：</label>
										<input type="number" name="" id="free_friend_id" value="" class="form-control" disabled>
									</div>
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">购买时长：</label>
										<input type="number" name="relatives_friends_duration" id="free_time" value="" class="form-control" placeholder="请输入购买时长(天)">
									</div>
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">购买金额：</label>
										<input type="number" name="total_fee" id="free_number" value="" class="form-control" placeholder="请输入购买金额10~3000(元)">
									</div>
								</div>	
							</div>
							<div class="err_info" style="display: none">购买金额：10~3000元</div>
							<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
								<input class="btn btn-w-m btn-info" type="button" value="确定" onclick="send_form('free')" />
								<input class="btn btn-w-m btn-info" type="button" value="取消" data-dismiss="modal" />
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--续费模态窗end-->

		<!--续费图片模式-->
		<div id="newModal7" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
				<div id="gray_Nr5" class=" modal-dialog">
					<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
						<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
							<div class="ibox-title">
								<h5>图片模式</h5>
								<div class="ibox-tools"  data-dismiss="modal">
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
							<form id="add_form7" method="post" action="__URL__/add_service_order"><!--图片续费的url-->
								<div class="ibox-content jqGrid_wrapp_qx">
									<div class="form-inlin7">
										<input type="text" name="register_relatives_friends_id" style="display: none" id="free_img_friend_id_hide">
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">亲友圈ID：</label>
											<input type="number" name="" id="free_img_friend_id" value="" class="form-control" disabled>
										</div>
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">购买时长：</label>
											<input type="number" name="img_msg_duration" id="freeimg_time" value="" class="form-control" placeholder="请输入购买时长(天)">
										</div>
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">购买金额：</label>
											<input type="number" name="total_fee" id="freeimg_number" value="" class="form-control" placeholder="请输入购买金额10~3000(元)">
										</div>
									</div>	
								</div>
								<div class="err_info" style="display: none">购买金额：10~3000元</div>
								<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
									<input class="btn btn-w-m btn-info" type="button" value="确定" onclick= "send_form('free_img')" />
									<input class="btn btn-w-m btn-info" type="button" value="取消" data-dismiss="modal" />
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		<!--续费图片模式end-->

		<!--付费链接-->
		<div id="newModal8" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
			<div id="gray_Nr5" class=" modal-dialog">
				<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
					<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
						<div class="ibox-title">
							<h5>付费链接</h5>
							<div class="ibox-tools"  data-dismiss="modal">
								<a class="close-link">
									<i class="fa fa-times"></i>
								</a>
							</div>
						</div>
						<form id="add_form8" method="post" action="__URL__/">
							<div class="ibox-content jqGrid_wrapp_qx">
								<div class="form-inlin1">
									<!-- <input type="text" name="register_relatives_friends_id" style="display: none" class="friends_id"> -->
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">付费链接：</label>
										<textarea id="free_link" rows="3" class="form-control"></textarea>
									</div>
									<div class="input-group">
										<label class="input-group-addon" style="width: 160px">付费二维码：</label>
										<img id="free_imgs" src="">
									</div>
									
								</div>	
							</div>
							<!-- <div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
								<input class="btn btn-w-m btn-info" type="button" value="确定" onclick="send_form_ele('#add_form7',change_gid_type_success,false,'.form-inlin1')" />
								<input class="btn btn-w-m btn-info" type="button" value="取消" data-dismiss="modal" />
							</div> -->
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--付费链接end-->

		<!--设置亲友圈和图片的过期时间,这个以后可能会删掉-->
		<div id="newModal9" class="modal fade" tabindex="-1" role="dialog"  aria-hidden="false" data-backdrop="static">
				<div id="gray_Nr5" class=" modal-dialog">
					<div class="col-sm-7 col-zm-j col-zm-j2 modal-dialog">
						<div class="ibox float-e-margins float-e-margins-2 float-e-margins-3">
							<div class="ibox-title">
								<h5>图片模式</h5>
								<div class="ibox-tools"  data-dismiss="modal">
									<a class="close-link">
										<i class="fa fa-times"></i>
									</a>
								</div>
							</div>
							<form id="add_form9" method="post" action="__URL__/set_relatives_friends"><!--亲友圈和图片你的过期时间-->
								<div class="ibox-content jqGrid_wrapp_qx">
									<div class="form-inlin9">
										<input type="text" name="register_relatives_friends_id" style="display: none" id="set_time_friend_id">
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">亲友圈ID：</label>
											<input type="number" name="" id="set_tiem_gid" value="" class="form-control" disabled>
										</div>
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">亲友圈过期时间：</label>
											<input type="text" name="outdate" id="outdate" value="" class="form-control" placeholder="点击选择时间">
										</div>
										<div class="input-group">
											<label class="input-group-addon" style="width: 160px">图片过期时间：</label>
											<input type="text" name="back_img_end_date" id="back_img_end_date" value="" class="form-control" placeholder="点击选择时间">
										</div>
									</div>	
								</div>
								<div class="ibox-butz" style="text-align: center;padding-bottom: 20px;">
									<input class="btn btn-w-m btn-info" type="button" value="确定" onclick= "send_form_ele('#add_form9',settime_suc,false,'.form-inlin9')" />
									<input class="btn btn-w-m btn-info" type="button" value="取消" data-dismiss="modal" />
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		<!--设置亲友圈和图片的过期时间,这个以后可能会删掉end-->
	</body>
	    <script>
			function modal_free_back(t){ //购买时长返回参数
				console.log("购买时长的返回参数",t);
				var data = t.result;
				if(data.status==1){
					$("#free_link").val(data.data.url);
					$("#free_imgs").attr("src",data.data.img_code);
					$("#newModal6").modal("hide");
					$("#newModal7").modal("hide");
					$("#newModal8").modal("show");
				}
			}
			
			function settime_suc(a){ //直接设置亲友的圈的过期时间和图片的过期时间
				console.log(a.result);
				if(a.result.status==1){
					$("#newModal9").modal('hide');
					reLoadRowData();
				}else{
					alert("修改失败！");
				}
			}

			$(".gid_last_step").click(function(){ //在输入亲友圈id 的时候，点击返回上一步
				close_open(1);
			})
			$(".erweima_last_step").click(function(){ //在扫描二维码的时候，返回第二部，但是这用因为ajax是长轮询的方式，暂时放弃了。
				//close_open(2);
				long_ajax.abort();
				$.ajax({
					type: "get",
					url: "__URL__/Cancellation_relatives_friends",
					data: {
						pid:pid,
						gid:gid,
						back:"1"
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.status==1){
							close_open(2);
						}
					}
				})
			})
			function del_img_btn(){
				send_form_ele('#delimg_form',reLoadRowData);
				$("#del_img_Modal").modal("hide");
			}

			function step1(){ //第一步的时候，校验试用天数0-15
				if($("#test_time").val()>15||$("#test_time").val()<0){
					alert("试用天数不能超过15天");
				}else{
					send_form_ele('#add_form2',rejqGrid3,false,'.form-inlin2');
				}
			}
			function change_gid_type_success(a){
				if(a.result.status==1){
					$("#newModal5").modal('hide');
					reLoadRowData();
				}else{
					alert("修改失败！");
				}
			}
			function del_gid(t){ //注销亲友圈的接口，先调取java那边的，成功以后调取php那边的。
				var gid_del = $(".gid_del").val();
				register_relatives_friends_id = $(".register_relatives_friends_id_del").val();
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						// uid: window_QRLogin_uuid_test,
						// action: "cancel",
						// gid: gid_del,
						url:encodeURI("http://" + test_ip + "/internal/match.json?uid="+window_QRLogin_uuid_test+"&action=cancel"+"&gid="+gid_del)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.code==1){
							reLoadRowData();
							//send_form_ele('#repassword_form',reLoadRowData);
						}else if(data.code == -202){ //可能需要修改
							reLoadRowData();
							//send_form_ele('#repassword_form',reLoadRowData);
						}
					}
				})
			}
			function del_gid2(t){ //删除亲友圈，这样这条数据就不可以找回了。
				var gid_del = $(".gid_del").val();
				register_relatives_friends_id = $(".register_relatives_friends_id_del").val();
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						url:encodeURI("http://" + test_ip + "/internal/match.json?uid="+window_QRLogin_uuid_test+"&action=cancel"+"&gid="+gid_del)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.code==1){
							send_form_ele('#repassword_form2',reLoadRowData);
						}else if(data.code == -202){ //可能需要修改
							send_form_ele('#repassword_form2',reLoadRowData);
						}
					}
				})
			}
			$(".over_btn").click(function(){ //点击最后的关闭按钮，去掉所有的图片
				$("#login_box2 img").remove();
			})
			var pid = "";
			function rejqGrid3(a){ //前两步中，点击了下一步的回调函数,会返回结果ajax的结果
				if(a.result.status==1){
					$("#newModal3").modal("hide");
					$("#newModal1").modal("hide");
					$("#newModal2").modal("hide");
					//console.log(a);
					if(a.result.data.gid){
						gid = a.result.data.gid;
					}
					if(a.result.data.register_relatives_friends_id){
						register_relatives_friends_id = a.result.data.register_relatives_friends_id;
						$("#add_form1_hide").val(register_relatives_friends_id);//第二部的时候，需要一个亲友圈的id
					}
					if(a.result.data.pid){
						pid = a.result.data.pid;
					}
					if(a.result.data.next_step==1){
						$("#newModal2").modal("show");
					}else if(a.result.data.next_step==2){
						$("#newModal1").modal("show");
					}else if(a.result.data.next_step==3){
						status();
					}else if(a.result.data.next_step==4){
						status();
					}
				}
			}

			$("#open_modal").click(function(){ //点击添加亲友圈的时候，先去后台访问，知道从第几步开始
				check_step();
				null_input();
			})
			
			function check_step(){ //从后台获取从第几步开始
				$.ajax({
					type: "get",
                    url: "__URL__/get_progress_info",
					data:{
						bind_type:1
					},
                    async: true,
                    success: function(data) { 
						//$("#open_modal").bind("click");
						var data = JSON.parse(data);
						if(data.status==1){
							var next_step  = data.data.next_step;
							close_open(next_step);
							gid = data.data.gid;
							pid = data.data.pid;
							register_relatives_friends_id = data.data.register_relatives_friends_id; //给亲友圈id赋值
							$("#add_form1_hide").val(register_relatives_friends_id);//第二部的时候，需要一个亲友圈的id
						}else if(data.status==0){
							close_open(1);
						}
                    }
				})
			}
			
			function close_open(open_modal){ //根据里面传进去的数值，判断需要打开哪个模态窗
				$("#newModal2").modal("hide");
				$("#newModal1").modal("hide");
				$("#newModal3").modal("hide");
				$("#newModal4").modal("hide");
				if(open_modal==1){
					$("#newModal2").modal("show");
				}else if(open_modal==2){
					$("#newModal1").modal("show");
				}else if(open_modal==3){
					status();
				}else if(open_modal==4){
					status();
				}
			}

			function act_formatter(rowObject){ //操作中需要的格式化按钮
				var ags = '';
				for(a in rowObject){
					ags += a+'="'+''+rowObject[a]+'" ';
				}
				var str = "";
				str += '<input onclick="change(this)" '+ags+' type="button" value="删除"  data-toggle="modal" data-target="#delModal2" class="btn btn-danger" /> ';
				str += '<input onclick="change(this)" '+ags+' type="button" value="注销"  data-toggle="modal" data-target="#delModal" class="btn btn-danger" /> ';
				str += '<input onclick="free(this)" '+ags+' type="button" value="续费"  data-toggle="modal" data-target="#" class="btn  btn-success" /> ';
				str += '<input onclick="free_img(this)" '+ags+' type="button" value="图片服务"  data-toggle="modal" data-target="#" class="btn  btn-success" /> ';
				str+="</br>"
				//str += '<input onclick="watch_free(this)" '+ags+' type="button" value="支付链接"  data-toggle="modal" data-target="#newModal8" class="btn  btn-success" /> ';
				//console.log(is_break);
				
					//if(is_break==1){ //是否断开微信
						str += '<input onclick="change_gid_type(this)" '+ags+' class="btn btn-info" type="button" data-toggle="modal" data-target="#newModal5" value="修改"  />';
					//}else if(is_break==0){
						str += '<input onclick="get_check(this)" '+ags+' class="btn btn-info" type="button" data-toggle="modal" data-target="#" value="绑定微信"  />';
					//}else if(is_break==2){

					//}
				str += 	'<input onclick="settime(this)" '+ags+' type="button" value="设置"  data-toggle="modal" data-target="#newModal9" class="btn btn-info" /> ';
				return str;	
			}
			function free(t){ //续费服务
				$("#free_friend_id").val($(t).attr("gid"));
				var friends_id = $(t).attr("register_relatives_friends_id");
				$("#free_friend_id_hide").val(friends_id);
				$("#newModal6").modal("show");
			}
			function free_img(t){ //图片服务
				$("#free_img_friend_id").val($(t).attr("gid"));
				var friends_id = $(t).attr("register_relatives_friends_id");
				$("#free_img_friend_id_hide").val(friends_id);
				$("#newModal7").modal("show");
			}
			function settime(t){ //直接设置时间,可能会被删除
				$("#set_tiem_gid").val($(t).attr("gid"));
				$("#set_time_friend_id").val($(t).attr("register_relatives_friends_id"));
			}
			function send_form(type){ //监测输入的金额
				if(type=="free_img"){
					var money_number = $("#freeimg_number").val();
					//console.log(money_number);
					if(money_number>3000||money_number<10){
						$(".err_info").show();
					}else{
						$(".err_info").hide();
						send_form_ele('#add_form7',modal_free_back,false,'.form-inlin7');
					}
				}else if(type=="free"){
					var money_number = $("#free_number").val();
					//console.log(money_number);
					if(money_number>3000||money_number<10){
						$(".err_info").show();
					}else{
						$(".err_info").hide();
						send_form_ele('#add_form6',modal_free_back,false,'.form-inlin7');
					}
				}
				
			}
			function change_gid_type(t){ //修改亲友圈类型
				
				var friends_id = $(t).attr("register_relatives_friends_id");
				$(".friends_id").val(friends_id);
				var describe_change = $(t).attr("describe");
				$("#describe_change").val(describe_change);
				check_img_server(friends_id);
				var back_img_time_val = $(t).attr("back_img_end_time").split(" ")[0];
				console.log(friends_id);
				if(back_img_time_val=="0000-00-00"){
					$("#back_time_change").val("");
				}else{
					$("#back_time_change").val(back_img_time_val);
				}
				
				if($(t).attr("content_type")==0){
					$(".gid_type_change").val("0");
					$(".back_img_div_change").hide();
					$(".back_img_tit_change").hide();
					$(".back_img_time_change").hide();
				}else if($(t).attr("content_type")==1){
					$(".gid_type_change").val("1");
					if($(t).attr("back_img")==""||$(t).attr("back_img")==null||$(t).attr("back_img")==undefined){
						$(".back_img_show").attr("src","http://assistant.parlouries.com:8800/assistant/data/back_img/default/0.71188900_1542260702.png").css("width","100px");
					}else{
						$(".back_img_show").attr("src",$(t).attr("back_img")).css("width","100px");
					}
					
					$(".back_img_div_change").show();
					$(".back_img_tit_change").show();
					$(".back_img_time_change").show();
				}

			}
			
			function check_img_server(register_relatives_friends_id){ // 查询图片服务,看这个亲友圈是否有图片的服务。
				$.ajax({
					type: "post",
					url: "__URL__/check_img_code",
					data: {
						register_relatives_friends_id:register_relatives_friends_id
					},
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.data){ //可以修改为图片
							$(".gid_type_change option[value='1']").show();
						}else{ //只能修改为文字
							$(".gid_type_change option[value='1']").hide();
						}
					}
				})
			}

			$(".gid_type_change").change(function(){
				var content_type = $(this).val();
				if(content_type==0){
					$(".back_img_div_change").hide();
					$(".back_img_tit_change").hide();
					$(".back_img_time_change").hide();
				}else if(content_type==1){

					$(".back_img_div_change").show();
					$(".back_img_tit_change").show();
					$(".back_img_time_change").show();
				}
			})
			
			function get_check(t){ //点击绑定微信按钮的时候，去java后台查询，能不能绑定微信
				var gid_t =  $(t).attr("gid");
				gid = gid_t;
				register_relatives_friends_id = $(t).attr("register_relatives_friends_id");
				// pi("match",true);
				status(true); //这里的参数是为了显示pi（）中错误，而不需要退回到第二部
			}

			function outtime(rowObject){ //格式化到期时间
				var out_time = (rowObject.outtime)*1000;
				return (new Date(out_time)).Format("yyyy-MM-dd hh:mm:ss");
			}

			function change(t){ //点击注销的时候，把注销按钮上的attr赋值到提示框中
                $(".pid_del").val($(t).attr("pid"));
                $(".gid_del").val($(t).attr("gid"));
				$(".register_relatives_friends_id_del").val($(t).attr("register_relatives_friends_id"));
            }

			//修改成功后重新格式化数据
			function reLoadRowData(obj){
				$('#myModal1').modal('hide');
				$("#delModal").modal("hide");
				$("#delModal2").modal("hide");
				$("#changeModal").modal("hide");
				$("#table_list_1").jqGrid('setGridParam', {  
                    datatype : "json",  
                    url :   '__URL__/relatives_friends_list',
					postData:{bind_type:1}
                }).trigger("reloadGrid");
			}
			var is_break = 0;//监测这个是否和后台断开的状态  0:彻底的断开了  1：使用中   2：断开了，但是拿到了验证码
			
			// function get_status(rowObject){
			// 	return "获取数据中...";
			// }
			
			function get_status_fun(t){
				//console.log(t);
				for(var i=0;i<t.length;i++){
					if(t[i]["overdue"]==1){ //过期
						jQuery("#table_list_1").jqGrid('setRowData',t[i]["register_relatives_friends_id"],{_status:"已过期"});
					}else if(t[i]["overdue"]==0){
						get_status1111(t[i]["gid"],t[i]["register_relatives_friends_id"],function(fid){
						//console.log("已断开");
						//console.log(fid);
						//$("#table_list_1").
							jQuery("#table_list_1").jqGrid('setRowData',fid,{_status:"已断开"});
						},function(fid){
							jQuery("#table_list_1").jqGrid('setRowData',fid,{_status:"使用中"});
						},function(fid,keycode){
							//console.log("执行到了这里",keycode,fid)
							jQuery("#table_list_1").jqGrid('setRowData',fid,{_status:keycode});
						});
					}
					
				}
			}

			function get_status1111(gid,fid,callback,callback2,callback3){	
				//var gid = rowObject.gid;			
				var action = "match";
				var status ="";
				//var register_relatives_friends_id = rowObject.register_relatives_friends_id;
				var register_relatives_friends_id = fid;
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						//"uid": window_QRLogin_uuid_test,
						"url":encodeURI("http://" + test_ip + "/internal/status.json?uid="+window_QRLogin_uuid_test)
					},
					contentType: "application/json",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						//console.log(data);
						if (data.status == -1 || data.status == 0) { //显示二维码
							status = "已断开，请绑定微信";
							callback(fid);
						} else { //不用显示二维码
							if(data.status == 3){ //跳过扫码这一步，直接请求群配对
								get_match(window_QRLogin_uuid_test,gid,fid,callback2,callback3);
							}
						}
					}
				})
				return status;	
			}
			
			function get_match(window_QRLogin_uuid_test,gid,fid,callback2,callback3){
				var status = "";
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						url:encodeURI("http://" + test_ip + "/internal/match.json?uid="+window_QRLogin_uuid_test+"&action="+"match"+"&gid="+gid)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						//console.log(data);
						var data = JSON.parse(data);
						if(data.code == -202){
							
						}else if(data.code == 1){
							save_code(fid,data.keyword);//保存群匹配助手
							//console.log("这里应该有群助手匹配码",data);
							callback3(fid,data.keyword);
						}
						get_target(gid,register_relatives_friends_id,fid,callback2,callback3);
						return status;
					}
				})

			}

			function get_target(gid,register_relatives_friends_id,fid,callback2,callback3){ //监测状态的target
				var status ="";
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						// uid: window_QRLogin_uuid_test,
						// gid: gid,
						url:encodeURI("http://" + test_ip + "/internal/target.json?uid="+window_QRLogin_uuid_test+"&gid="+gid)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.code==1){
							status = "使用中";
							callback2(fid);
						}else if(data.code == 2){
							status =  "匹配码匹配中";
							//console.log("从数据中库拿的数据",get_code(register_relatives_friends_id,callback3))
							get_code(fid,callback3);//去数据库中拉数据
							get_target(gid,register_relatives_friends_id,fid,callback2,callback3);
						}else if(data.code==-202){
							get_match(window_QRLogin_uuid_test,gid,fid,callback2,callback3)
						}else if(data.code==3){
							status =  "匹配码匹配中";
							get_code(fid,callback3);//去数据库中拉数据
						}
						//console.log("get_target中的status",status);
						return status;
					}
				})
			}



			$(document).ready(function(){ //直接导入php后台的数据
				$("#table_list_1").jqGrid({
					height:'auto',
					styleUI:'Bootstrap',
					url:'__URL__/relatives_friends_list',
					postData:{
						bind_type:1
					},
					datatype: "json",
					autowidth: false,
					shrinkToFit: true,
					rowNum: 25,
					rowList: [10, 25, 50, 100],
					colNames: ["游戏名称","亲友圈ID","截止时间","状态","备注","亲友圈类型","图片到期时间","操作"], //"代理账号",
					colModel: [
						// {
						// 	name:'xl_user_name',
						// 	width:100
						// },
						{
							name:'pid_name',
							width:100,
						},
						{
							name: 'gid',
							width: 80,
						},
						{
							name: '_outtime',
							formatter: function(cellvalue,options,rowObject){
								//return formatter(cellvalue,options,rowObject,outtime);
								return outtime(rowObject);
							}
						},
						{
							name:"_status",
							formatter: function(cellvalue,options,rowObject){
								// console.log(rowObject);
								// console.log(cellvalue);
								if(cellvalue){
									return cellvalue
								}else{
									return "等待数据中..."
								}
							}
						},
						{
							name:"describe",
							width:160
						},
						{
							name:"content_type_img",
							width:160,
							formatter: function(cellvalue,options,rowObject){
								//return formatter(cellvalue,options,rowObject,content_type_img);
								return content_type_img(rowObject);
							}
						},
						{
							name:"_back_img_end_time",
							formatter: function(cellvalue,options,rowObject){
								//return formatter(cellvalue,options,rowObject,back_img_time);
								return back_img_time(rowObject);
							}
						},
						{
							width:370,
							name: '_act',
							sortable: false,
							formatter: function(cellvalue,options,rowObject){
								//return formatter(cellvalue,options,rowObject,act_formatter);
								return act_formatter(rowObject);
							}
						}
					],
					pager: "#pager_list_1",
					viewrecords: true,
					hidegrid: false,
					jsonReader:{
						id:"register_relatives_friends_id"
					},
					loadComplete:function(t){
						get_status_fun(t);
					}
				});
			});
			
			
			
			$('.jqgrid_box').resize(function(){
				setGridWidth($(this).find('.table_list'),this);
			});
			function content_type_img(t){
				if(t.content_type==0){ 
					return "文字";
				}else{
					var id = t.register_relatives_friends_id;
					if(t.back_img){
						var img = "<img style='width:50px;' src="+t.back_img+">";
						img += '<input onclick="del_img('+id+')" '+''+' class="btn btn-info" type="button" data-toggle="modal" data-target="#del_img_Modal" value="设为默认图片"  />';
					}else{
						var img = "<img style='width:50px;' src="+"http://assistant.parlouries.com:8800/assistant/data/back_img/default/0.71188900_1542260702.png"+">";
					}
					return img;
				}
			}
			
			function back_img_time(rowObject){
				//console.log(rowObject);
				
					//console.log(rowObject.back_img_end_time);
					if(rowObject.back_img_end_time==""||rowObject.back_img_end_time==null||rowObject.back_img_end_time==0){
						return "";
					}else{
						var time = rowObject.back_img_end_time*1000;
						return (new Date(time)).Format("yyyy-MM-dd hh:mm:ss");
					}
			}

			function del_img(id){
				$(".del_img_id").val(id);
			}

            var json_area = {}; //存放地区数据的json
            function load_area() { //获取地区的ajax
                $.ajax({
                    type: "get",
                    url: "__URL__/get_pid_list", //获取地区的接口
                    async: true,
                    success: function(data) { //
                        var data = JSON.parse(data);
                        if(data.status == 1){
                            json_area = data.data;
                            deal_area(json_area);
                        }
                    }
                });
            }
            function deal_area(data){
				var province = [];
				var province_id = [];
				var area_json = {};
				for( i in data){
					if(province_id.indexOf(data[i]["region_id"])==-1){
						province_id.push(data[i]["region_id"]);
						if(data[i]["region_name"]==null||data[i]["region_name"]=="null"){
							province.push("其他")
						}else{
							province.push(data[i]["region_name"]);
						}
					}
				}
				console.log(province_id,province);
				for(var i=0;i<province_id.length;i++){
					var region_id = province_id[i];
					var arr = [];
					for(j in data){
						if(region_id==data[j]["region_id"]){
							arr.push({
								"pid_name":data[j]["pid_name"],
								"pid":data[j]["pid"],
								"group_id":data[j]["group_id"]
							})
						}
					}
					area_json[province[i]] = arr;
				}
				console.log(area_json);
				fun_load_area(area_json);
			}
            function fun_load_area(area_json){ //给地区选择赋值的函数
				for (var  item in area_json) {
					if (area_json.hasOwnProperty(item)) {
						var element = area_json[item];
						$("<option></option>").attr("value",item).text(item).appendTo($(".area_c"));
					}
				}
				change_p(area_json)
            }
			function change_p(data){
				$(".area_c").change(function(){
					$(".add_game").remove();
					var str = "";
					var place = $(this).val();
					
					for(var i in data[place]){
						str += '<option class="add_game" group_id = "'+data[place][i]["group_id"]+'" value="'+data[place][i]["pid"]+'">'+data[place][i]["pid_name"]+'</option>';
					}
					$(".area").append(str);
				})
			}
            load_area();//获取地区的函数
			$(".area").change(function(){ //当用户选择不同的地区id的时候，改变下面的显示项
				$(".group_id2 input").val("");
				$(".group_id1 input").val("");
				var group_id = $(this).find('option:selected').attr("group_id");
				if(group_id==1){
					$(".group_id2").hide();
					$(".group_id1").show();
				}else{
					$(".group_id2").show();
					$(".group_id1").hide();
				}
			})
			$(".gid_type").change(function(){
				var gid_type = $(this).val();
				if(gid_type==0){
					$(".back_img_div").hide();
					$(".back_img_tit").hide();
					$(".back_img_time").hide();
				}else if(gid_type==1){
					$(".back_img_div").show();
					$(".back_img_tit").show();
					$(".back_img_time").show();
				}
			});
			$(".back_img").change(function(e){
				
				loadImageFile("#upload_img","#img_show");
		
			})
			$("#back_img_change").change(function(){
				
				loadImageFile("#back_img_change","#back_img_change_show");
			})
		</script>
		<script type="text/javascript">
			var window_QRLogin_uuid = ""; //从微信获取到的uuid
			var get_url = '__ROOT__/wechat.php';//"http://assistant.parlouries.com:8800/wechat.php"; //"http://192.168.9.209:8800/wechat_login/wechat.php"; //php写的转发的接口
			// var get_uuid_url =
			// 	"https://login.wx.qq.com/jslogin?appid=wx782c26e4c19acffb&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage&fun=new&lang=zh_CN&_=1535102432168";
			var get_uuid_url = "https://login.wx.qq.com/jslogin?appid=wx782c26e4c19acffb&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage&fun=new&lang=zh_CN&_=1544586536615";
			var window_QRLogin_uuid_test = ""; //从闲徕得到的uid
			var ticket = ""; //从微信获取的，java后台登录的时候需要
			var test_ip = "127.0.0.1:8848";// 公网
			//var test_ip = "127.0.0.1:8849"; //测试公网 
			//var test_ip = "192.168.1.59:9949"; //古少阳本地
			//var test_ip = "chessvans.f3322.net:9949";
			var gid = ""; //用户自己填写的亲友圈id

			function get_uid_gid (){ //获取uid的接口
				$.ajax({
					type: "get",
					url: "__URL__/member_info",
					async: true,
					success: function (data) { //获取的微信的返回值
					var data = JSON.parse(data);
						if(data.status==1){	
							window_QRLogin_uuid_test = data.info.member_unique_code;
						}
					}
				});
			}
			get_uid_gid();
			
			function status(flag) { //判断用不用显示二维码
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						//"uid": window_QRLogin_uuid_test,
						"url":encodeURI("http://" + test_ip + "/internal/status.json?uid="+window_QRLogin_uuid_test)
					},
					contentType: "application/json",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if (data.status == -1 || data.status == 0) { //显示二维码
							get_erweima();
							$("#newModal3").modal("show");
						} else { //不用显示二维码
							if(data.status == 3){ //跳过扫码这一步，直接请求群配对
								$("#newModal3").modal("hide");
								$("#newModal4").modal("show");
								get_yan(flag);
							}
						}
					}
				})
			}

			function get_erweima() { //从微信获取二维码
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						"url": encodeURI(get_uuid_url)
					},
					async: true,
					success: function (data) { //获取的微信的返回值，但是他不是正确的JSON.stringify的格式，所以只能按照字符串来处理
						var window_QRLogin_code = data.split("=")[1].split(";")[0];
						if (window_QRLogin_code == 200) { //这里的两百是带空格的
							window_QRLogin_uuid = data.split('"')[1];//给uuid赋值
							$("#er_img").attr("src", "https://login.weixin.qq.com/qrcode/" + window_QRLogin_uuid); //获取到了二维码
							$("#er_img").css("visibility", "visible");
							
							$(".sub_title").text("使用手机微信扫码登录").show();
							login(); 
						}
					}
				});
			}

			var old_window_code = ""; //用来判断是否已经扫过二维码的变量，如果有值，则代表已经扫过了，否则表示没有扫过。
			var long_ajax = "";
			function login() { //调取登录接口，监测用户扫码
				// var login_url = "https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=" + window_QRLogin_uuid +
				// 	"&tip=1&r=-2030253709&_=1535333577780";
				var login_url = "https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=" + window_QRLogin_uuid +
				 	"&tip=1&r=1602170851&_=1544586055483";
	long_ajax =	$.ajax({
					type: "get",
					url: get_url,
					data: {
						"url": encodeURI(login_url)
					},
					async: true,
					success: function (data) {
						
						var window_code = data.split("=")[1].split(";")[0];
						if (window_code == 408) { //表示用户还没有扫码，继续回调自身
							login();
						} else if (window_code == 201) { //表示有人扫码但是没有点击手机上的登录
							if (old_window_code == "") { //主要是为了避免重复的给页面赋值
								if(data.split(";").length>2){
									var base_64_img = data.split("=")[2].split("'")[1];
								}else{
									var base_64_img = "https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/562c11dfa9ec8a135ea6851bf103918fa1ecc089.jpg";//微信默认头像
								}
								var img = $("#er_img");
								img.attr("src", base_64_img);
								img.addClass("header_logo");
								old_window_code = 201;
								$(".sub_title").hide();
								$(".sub_desc").text("请在手机上确认登录！").css("color","#a3a3a3");
								$(".change").show();
								login();
							} else {
								login();
							}
						} else if (window_code == 200) {
							var window_redirect_uri = data.split(";")[1].split('"')[1];
							ticket = window_redirect_uri.split("=")[1].split("&")[0];//获得ticket
							$(".sub_desc").text("微信登录成功！请稍候...").css("color","#a3a3a3");;
							login_true(window_QRLogin_uuid, ticket); //调取后台的登录接口登录
						} else if (window_code == 400) { //一直没人扫码，然后就把这个页面刷新
							alert("请刷新后重试！");
							window.location.reload();
						}
					}
				});
			}
			
			//Destroyed(-1), Unknown(0),显示二维码    Initiating(1), Initiated(2), Targeting(3), Working(5);不显示
			function login_true(window_QRLogin_uuid, ticket) { //登录到java后台系统
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						// uid: window_QRLogin_uuid_test,
						// uuid: window_QRLogin_uuid,
						// ticket: ticket,
						url:encodeURI("http://" + test_ip + "/internal/login.json?uid="+window_QRLogin_uuid_test+"&uuid="+window_QRLogin_uuid+"&ticket="+ticket)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.code==1){ //登录自己后台成功以后
							push_login_success_staus();
							$("#newModal3").modal("hide");
							$("#newModal4").modal("show");
							get_yan(); //后台登录成功以后，不是直接调用注册群，而是向php的后台请求有没有验证码
						}else if(data.code==-201){
							console.log("登录自己的后台失败！");
							// $(".sub_desc").text("登录本系统失败！").css("color","red");
							old_window_code = "";//给置空，这样才能显示头像。
							$('#login_box img').removeClass("header_logo");//让二维码恢复原始的大小
							get_erweima();
							$("#newModal3").modal("show");
							$(".sub_desc").text("请更换微信后重新扫码").css("color","red");
						}else if(data.code==-1){
							alert("登录失败，请重试")
						}else if(data.code==-200){
							alert("登录失败，请重试");
						}
						
					}
				})
			}
			
			function push_login_success_staus (){ //向后台发送数据，保存当前是扫码成功的状态
				$.ajax({
					type: "get",
					url: "__URL__"+"/wxsm_tzh",
					async: true,
					success: function (data) {
						
					}
				})
			}
			
			function pi(action,flag) { //注册群 注销群
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						// uid: window_QRLogin_uuid_test,
						// action: action,
						// gid: gid,
						url:encodeURI("http://" + test_ip + "/internal/match.json?uid="+window_QRLogin_uuid_test+"&action="+action+"&gid="+gid)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						console.log("match.json",data);
						var data = JSON.parse(data); 
						if (data.code == 1 && action == "match") {
							//console.log(data.keyword);
							$(".qunzhushou").text(data.keyword);
							post_yan(data.keyword); //保存验证码
							pi2();                                                                                                                                                                                
						}else if(data.code == -202){
							
							if(flag!=true){ //判断是不是直接点击的获取验证码的按钮
								if($(".err").length==0){
									$("<p class='err'></p>").text("此朋友圈已经注册过了，请重新填写！").css({"color":"red"}).appendTo($(".form-inlin1"));
								}
								//close_open(2);
							}else{ //如果是的话，直接报错，不用和上面的一样，返回上一步
								$(".title").hide();
								$(".qunzhushou").text("此亲友圈正在使用中，请勿重复绑定！");
							}
							
						}
					}
				})
			}
		
			function pi2() { //注册群成功以后，检测到群里面发送了指定的通讯密钥以后，绑定群的函数
				$.ajax({
					type: "get",
					url: get_url,
					data: {
						// uid: window_QRLogin_uuid_test,
						// gid: gid,
						url:encodeURI("http://" + test_ip + "/internal/target.json?uid="+window_QRLogin_uuid_test+"&gid="+gid)
					},
					contentType: "application/json;charset=utf-8",
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if (data.code == 2) { //阻塞检测，重新发起请求
							pi2();
						} else if (data.code == 1) { //成功，获取到了绑定群的信息
							var portrait = data.portrait;
							$("<img />").attr("src", portrait).appendTo($("#login_box2")).css({"margin":"30px auto","display":"block"});
							$(".title").hide();
							$(".qunzhushou").text("此群已成功收到开房和结算通知！");
							$(".ibox_butz_only").show();
							push_complete_staus();//向后台发送完成通知
							del_yan();//删除php数据库中的check_code
							null_input();//清空所有的输入框和选择框，还有报错
						} else {
							pi("match");
						}
					}
				})
			}

			function push_complete_staus(){ //向后台发送完成通知
				$.ajax({
					type: "get",
					url: "__URL__"+"/register_relatives_friends_finish",
					async: true,
					success: function (data) {
						$("#table_list_1").jqGrid('setGridParam', {  //重新加载数据
							datatype : "json",  
							url :   '__URL__/relatives_friends_list',
							postData:{bind_type:1}
						}).trigger("reloadGrid");
					}
				})
			}

			var register_relatives_friends_id = "";
			function get_yan(flag){ //获取php的验证码
				$.ajax({
					type: "get",
					url: "__URL__"+"/relatives_friends_info",
					data:{
						register_relatives_friends_id:register_relatives_friends_id
					},
					async: true,
					success: function (data) {
						var data = JSON.parse(data);
						if(data.status==1){
							if(data.data.check_code!=""){ //获取到了验证码，跳过match.json接口，直接在页面显示，然后循环监测
								$(".qunzhushou").text(data.data.check_code);
								pi2();
							}else{
								pi("match",flag); //没有获取到验证码，向java后台请求
							}
						}
					}
				})
			}
			



			function save_code(register_relatives_friends_id,check_code){ //监测状态，保存群验证码
				$.ajax({
					type: "get",
					url: "__URL__"+"/save_check_code",
					data:{
						register_relatives_friends_id:register_relatives_friends_id,
						check_code:check_code
					},
					async: true,
					success: function (data) {
						//console.log("保存群匹配码",data);
						//console.log("保存验证码成功！");
					}
				})
			}
			function get_code(register_relatives_friends_id,callback3){ //检测状态，获取群验证码
				$.ajax({
					type: "get",
					url: "__URL__"+"/relatives_friends_info",
					data:{
						register_relatives_friends_id:register_relatives_friends_id
					},
					async: true,
					success: function (data) {
						//console.log(data);
						var data = JSON.parse(data);
						console.log("获取到的群匹配码",data.data.check_code);
						callback3(register_relatives_friends_id,data.data.check_code);
						//return data;
					}
				})
			}



			function post_yan(check_code){ //发送给php保存验证码
				$.ajax({
					type: "get",
					url: "__URL__"+"/save_check_code",
					data:{
						register_relatives_friends_id:register_relatives_friends_id,
						check_code:check_code
					},
					async: true,
					success: function (data) {
						//console.log("保存验证码成功！");
					}
				})
			}

			function del_yan(){ //要求后台删除验证码
				$.ajax({
					type: "get",
					url: "__URL__"+"/remove_check_code",
					data:{
						register_relatives_friends_id:register_relatives_friends_id
					},
					async: true,
					success: function (data) {
						//console.log("删除验证码成功！");
					}
				})
			}

			function null_input (){ //清空所有输入框的数据。
				$(".input-group input").val("");
				$(".err").remove();
				$("select").val(" ");
				$(".title").show();
			}
			laydate.render({ //图片模式下，时间弹窗
				elem: '#back_time'
			});
			//back_time_change
			laydate.render({ //修改图片模式下，时间弹窗
				elem: '#back_time_change'
			});
			laydate.render({ //直接设置过期时间
				elem: '#back_img_end_date',
				type:"datetime"
			});
			laydate.render({ //直接设置过期时间
				elem: '#outdate',
				type:"datetime"
			});
		</script>
		<!--读取的依赖js-->
		<!-- <script src="__PUBLIC__js/iscroll-zoom.js"></script>
		<script src="__PUBLIC__js/hammer.js"></script>
		<script src="__PUBLIC__js/lrz.all.bundle.js"></script>
		<script src="__PUBLIC__js/jquery.photoClip.js"></script>
		<script>
			//读取图片的截取弹窗js…………反正是很多的弹窗
			var clipArea = new bjj.PhotoClip("#clipArea", {
				size: [353, 260],
				outputSize: [353, 260],
				file: "#file",
				view: "#view",
				ok: "#clipBtn",
				outputType:"png",
				loadStart: function() {
					console.log("照片读取中");
				},
				loadComplete: function() {
					console.log("照片读取完成");
				},
				clipFinish: function(dataURL) {
					console.log(dataURL);
				}
			});
		</script> -->
		<script type="text/javascript">

		</script>
</html>